<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>insertSort</title>
</head>

<body>
    <script>
        function insertSort(arr) {
            for (var i = 1; i < arr.length; i++) {
                var temp = arr[i];
                var j = i - 1;
                while (j >= 0 && arr[j] > temp) {
                    arr[j + 1] = arr[j];
                    j--;
                }
                arr[j + 1] = temp;
            }
            return arr;
        }
        var arr = [1, 45, 37, 5, 48, 15, 37, 26, 29, 2, 46, 4, 17, 50, 52];
        console.log(insertSort(arr));
    </script>
</body>

</html>